package com.safewind.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.safewind.model.User;
import com.safewind.util.ConstantUtil;

@Controller
@RequestMapping("/redirect")
public class RedirectController {

	@RequestMapping("/homepage")
	public String homepage() {
		return "homepage";
	}

	@RequestMapping("/login")
	public String login() {
		return "login";
	}

	@RequestMapping("/reg")
	public String reg() {
		return "reg";
	}

	@RequestMapping("/admin")
	public String admin(HttpSession session) {
		User user = (User) session.getAttribute("user");
		if (user.getUserName().equals(ConstantUtil.ADMIN)) {
			return "admin";
		}
		return "login";
	}
}
